<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>上传文件</title>
    <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
    <script src="http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js"></script>
    <script>
        function upload(){
            var formData = new FormData(); //创建一个formData对象实例
            var excelFile = $("#uploadFile").get(0).files[0];
            formData.append("excelFile",excelFile)
            $.ajax({
                url: '/upload',
                data: formData,
                type: 'post',
                contentType:false, // 必须false才会自动加上正确的Content-Type
                processData: false, // 必须false才会避开jQuery对 formdata 的默认处理,XMLHttpRequest会对 formdata 进行正确的处理
                success: function (resp){
                    console.log(resp);
                }
            })
        }
    </script>
</head>
<body>
    <p>上传的文件</p>
    <input multiple="multiple" type="file" id="uploadFile">
    <br>
    <br>
    <button onclick="upload()">上传</button>
</body>
</html>